<!-- 供应商分组 -->
<template>
  <div>
    <ChooseShow :menus="menus" @GetTableId="GetTableId" title='全部分类'>
      <div slot="operation" class="Head_Top">
        <div class="Top_one">
          <el-button @click="addgroup" size="small" type="primary">新增</el-button>
        </div>
        <div class="Top_two">
          <div class="Top_two_one">
           <el-input
            placeholder="请输入内容"
            v-model="listfrom.KeyWord">
            <i slot="suffix" @click="search" class="el-input__icon el-icon-search"></i>
          </el-input>
          </div>
        <div class="Top_two_two1">
          <el-button icon="el-icon-refresh" size="small" class="refresh" @click="Toreload"></el-button>
          <!-- <i class="iconfont icon-shuaxin" @click="Toreload"></i> -->
        </div>
        </div>
        <!-- <el-button @click="modal12 = true" type="primary">点击编辑</el-button> -->
      </div>
      <div slot="table">
        <table-cmp
      style="width:100%"
      class="table_cmp"
        :loading="loading"
        :table-data="tableData"
        :table-label="tableLabel"
        @handleButton="handleButton"
        @rowClick="rowClick"
        @cellClick="cellClick"
        @handleSortChange="handleSortChange"
        @handleSelectionChange="handleSelectionChange"
      ></table-cmp>
      <div style="text-align: right;">
        <el-pagination
      v-if="tatolpage<10"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="listfrom.PageIndex"
        :page-sizes="[10, 15, 20]"
        layout=" prev, pager, next"
        :total="tatolpage">
      </el-pagination>
      </div>
      </div>
      
    </ChooseShow>
    <group ref="group"></group>
  </div>
</template>

<script>
var occupancyDisplay = {
  template: `<div>
            <el-button type="text" size="small">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
  
  </div>`,
  props: ['row'],
  created() {
    },
  methods: {
    shenhDetail(row) {
      this.$emit('shenh-detail', row);
      // console.log(this.row,'1111111');
      
    },
    seeDetail(row) {
      this.$emit('see-detail', row);
      // console.log(this.row,'1111111');
      
    }
  }
};
var that;
import ChooseShow from "@/components/ChooseShow";
import group from "./dialog/group";
export default {
  name: "",
  data() {
    return {
      modal12: false,
      loading: false,
      tatolpage: 0,
      tableData: [],
       listfrom:{
        "Status":'',
        "KeyWord":'',
        "Status":'',
        "PageSize":10,
        "PageIndex":1
      },
      tableLabel: [
        { label: '状态', param: 'Status', width: '100', align: 'center', sortable: false, render: (row) => {
            if (row.Status == 0) {
              return '草稿'
            } else if (row.Status == 1) {
              return '待审批'
            } else if (row.Status == 2) {
              return '审核通过'
            } else if (row.Status == 3) {
              return '作废'
            }
          }
        },
        { label: '用户名称', param: 'Name', align: 'center',width: '200', sortable: false },
        { label: '来源', param: 'Source', align: 'center', width: '150' ,render: (row) => {
            if (row.Source == 0) {
              return '用户注册'
            } else if (row.Source == 1) {
              return '管理员添加'
            }
          }
          },
        { label: '描述', param: 'Remark', align: 'center'},
        { label: '操作', align: 'center', width: '300',
           component:occupancyDisplay,listeners:{
            'dyapi-detail'(row) {
              that.dyapiDetail(row);
            },
            'delete-detail'(row) {
              that.deleteDetail(row);
            }
          }
      }
      ],
      fromData: {},
      columns: [],
      menus: [
        {
          name: "1",
          label: "内容管理",
          children: [
            { label: "文章管理" },
            { label: "评论管理" },
            { label: "举报管理" }
          ]
        },
        {
          name: "2",
          label: "用户管理",
          children: [{ label: "新增用户" }, { label: "活跃用户" }]
        },
        {
          name: "3",
          label: "统计分析",
          children: [
            { label: "新增和启动" },
            { label: "活跃分析" },
            { label: "时段分析" }
          ]
        }
      ]
    };
  },
  components: {
    group,
    ChooseShow
  },
  watch: {
    "$store.state.Purchasingmanagement.MNvalue.GetUsers":function (data){
        let DataContent = data.ReturnData.DataCount;
        this.tableData = data.ReturnData.Data;
    },
  },
  methods: {
    // 添加组
    addgroup(){
      this.$refs.group.dialogFormVisible = true;
    },
    getlistdata(){
      let obj = {
            "MN":"GetUsers",
            "RequestId":1,
            "UserId":1,
            "DataContent":this.listfrom
           }
             this.MIX_send(obj);
    },
    rowClick(data){},
    handleCurrentChange(data){
      this.listfrom.PageIndex = data;
      this.getlistdata();
    },
    handleSizeChange(data){
      // console.log(data,'handleSizeChange');
      this.listfrom.PageSize = data;
      this.getlistdata();
    },
    handleButton(data){},
    cellClick(data){},
    handleSortChange(data){},
    handleSelectionChange(data){},
    GetTableId(data){
      console.log(data);
    },
    Toreload(){
      this.listfrom={
        "Status":'',
        "KeyWord":'',
        "Status":'',
        "PageSize":10,
        "PageIndex":1
      }
      this.getlistdata();
    },
    search(){
      this.getlistdata();
    },
    // 表格上方筛选slot的事件回调
    add() {
      console.log("表格上方筛选slot的事件回调");
    },
    // 弹出框表单提交
    Commit() {
      console.log(this.$refs.PopForm.value);
    },
    // 弹出框底部标签页组件事件的回调
    edit(val) {
      console.log(val);
    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {
    that = this;
    this.getlistdata();
  },
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {}
};
</script>

<style lang="less" scoped>
.Head_Top{
  width: 100%;
  height: 51px;
  // overflow: hidden;
  display: flex;
  justify-content: space-between;
  .Top_one{
    width: 100px;
  }
  .Top_two{
    // flex: 1;
    display: flex;
    .Top_two_two{
      padding: 10px;
    }
  }
  .Top_three{
    width: 50px;
  }
}
</style>